package com.dudo;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;

public class Options extends Activity implements OnClickListener {

	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    	//start the activity from the last saved instance (if there was one)
        super.onCreate(savedInstanceState);
        
        //set the view to display (an XML from /res/layout)
        setContentView(R.layout.options_screen);
        
        //grab the checkbox and button from R (it's in the /res/layout/options_screen.xml file)
        CheckBox soundBox = (CheckBox) this.findViewById(R.id.options_sound_check);
        Button homeButton = (Button) this.findViewById(R.id.options_home_button);
        
        //set a listener for them
        soundBox.setOnClickListener(this);
        homeButton.setOnClickListener(this);
    }

	@Override
	public void onClick(View v) {
		int viewID = v.getId();
		
		switch(viewID) {
		//if it's the checkbox
		case R.id.options_sound_check:
			//if it's checked, do something
			if(((CheckBox) v).isChecked()) {
				((CheckBox)v).setText("Sound: On");
			}
			//if it's unchecked, do something else
			else {
				((CheckBox)v).setText("Sound: Off");
			}
			break;
			
		//if it's the home button
		case R.id.options_home_button:
			//create a new intent to switch the activity
			Intent intent = new Intent(this,Home.class);
			this.startActivity(intent);
			break;
			
		//default: do nothing
		default: break;
		}
	}
}
